Skip to content

Conversation

bsweeney
Copy link
Member

No description provided.

@bsweeney bsweeney added this to the 0.5.5 milestone Oct 16, 2023
@bsweeney bsweeney linked an issue Oct 16, 2023 that may be closed by this pull request
@bsweeney bsweeney force-pushed the ttf-spec-compliance branch from abe286c to c184f1b Compare October 16, 2023 01:08
@bsweeney bsweeney force-pushed the ttf-spec-compliance branch from c184f1b to c61a738 Compare October 16, 2023 01:17
@bsweeney bsweeney linked an issue Dec 12, 2023 that may be closed by this pull request
@bsweeney bsweeney force-pushed the ttf-spec-compliance branch 3 times, most recently from 84c64a7 to 89d295f Compare December 12, 2023 22:51
@bsweeney bsweeney force-pushed the ttf-spec-compliance branch 2 times, most recently from 432e04f to 4294913 Compare December 29, 2023 22:50
From the TrueType font specification section about the cmap table:

> No character code should be mapped to glyph index -1 (0xFFFF), which is a special value reserved in processing to indicate the position of a glyph deleted from the glyph stream.

ref #123
...before calculating the head table checksum. Per the head table specification:

> checkSumAdjustment: To compute set it to 0, calculate the checksum for the 'head' table and put it in the table directory, sum the entire font as a uint32_t, then store 0xB1B0AFBA - sum. (The checksum for the 'head' table will be wrong as a result. That is OK; do not reset it.)

ref #123
The number of tables in the font may change when generating a font file. Because the font header is dependent on the number of tables the values need to be recalculated.

ref #123
Per the spec:

> Table checksums are the unsigned sum of the longs in a table.
Per the spec:

> The length of any table is a multiple of four bytes, or that tables are padded with zero to four byte-aligned offsets. Actual table lengths recorded in the TableDirectory should not include padding.

fixes #119
Before this change when the font loca table was using the short format (glyph size / 2), an odd-numbered glyph byte length would be incorrectly record. To prevent this issue, when writing a font we will padd glyphs to align with a 4-byte boundary.

Note: Official guidance needed. The 4-byte boundary is based on table requirements, as well as being a multiple of 2.
Most name strings should be encoded with UTF-16BE per the spec, but there are situations where other encodings are required or acceptable. This change only addresses a subset of potential encodings.

fixes #70
A font with a format 2 cmap table will still re-encode with a format 4 cmap table.

relates to #123
This librarry relies on Unicode data for a number of functions (namely font re-encoding). Without a Unicode-encoded cmap table those functions do not work as expected.
@bsweeney bsweeney force-pushed the ttf-spec-compliance branch from 4294913 to 3ef0eed Compare December 30, 2023 16:07
@bsweeney bsweeney merged commit cca2a59 into master Jan 6, 2024
@bsweeney bsweeney deleted the ttf-spec-compliance branch January 6, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant